version 14.2
set more off

***************************************************************************************************************************
* THIS ROUTINE GENERATES FIGURE A.VIII OF WASEEM (2020) ROLE OF WITHHOLDING ...
***************************************************************************************************************************

use						"$project_data\STPAK_1996_2003_UBP_v1.dta", clear
keep                	if business_sts=="1" 
g						ind=real(substr(item_cd,1,4))
drop					if ind<1600
drop					if ind>=2500 & ind<2800
drop					if fy==1996
drop					period
g						period=mofd(taxperiod)
qui						sum period
replace					period=period-r(min)+1
bys						period: g index=_n
local					var="impopurch_ag"
g						logvar_real=log(`var')
qui						areg logvar_real i.period, absorb(regnor)
g 						betahats=0
qui						sum period
local					nr=r(max)
forvalue				s=1/`nr' {
						cap replace betahats=_b[`s'.period] if period==`s' 
}
local					var="purch_ag"
g						logvar2=log(`var')
g 						betahat2=0
qui						areg logvar2 i.period, absorb(regnor)
qui						sum period
local					nr=r(max)
forvalue				s=1/`nr' {
						cap replace betahat2=_b[`s'.period] if period==`s'
}
#d						;
twoway  				(connected  betahats period if period>1 & index==1,sort lwidth(thick) lcolor(red) mcolor(red) msymbol(o))
						(connected  betahat2 period if period>1 & index==1,sort lwidth(thick) lcolor(midblue) mcolor(midblue) msymbol(o) lpattern(shortdash)),
						xtitle("Month of the Year") xscale(titlegap(*10))
						xlabel(1 "97" 13 "98" 25 "99" 37 "00" 49 "01" 61 "02" 73 "03" 85 "04")
						yscale(r(0))  yscale(titlegap(*10)) ytitle("Within-firm Mean of Log Inputs") ylabel(-2(1)2)
						xline(13 25 37, lpatter(dash) lcolor(green)) 
						legend(region(style(none)) label(1 "Imported Inpus") label(2 "All Inputs"))
						graphregion(fcolor(white) style(none) color(white) margin(0 0 0 2)) bgcolor(white);
graph 					export "$project_output\PanelDD_lnImportedVsAllInputs_UBP.eps", replace;
#d						cr

